package airacrobats.game.object;

import airacrobats.io.data.JWavefrontModel;
import airacrobats.sound.Sound3D;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.swing.JPanel;
import javax.vecmath.Point3f;

/**
 * This class represents a sky object.
 */
public class Sky extends GameObject
{
    /**
     * The sky size (from the origin).
     */
    private final static float LENGTH = 1000.0f;

    /**
     * @param model The model.
     * @param cameraSight The camera maximum sight.
     */
    public Sky(JWavefrontModel model, float cameraSight)
    {
        super(model, null, new Point3f(0.0f, 0.0f, 0.0f), new Sound3D[] { });
    }

    /**
     */
    public void setupInfoPanel(JPanel owner)
    {
    }

    /**
     */
    @Override
    public void transformModelview(GL2 gl)
    {

    }
    
    /**
     */
    protected void doDraw(GLAutoDrawable drawable, JWavefrontModel model)
    { 
        GL2 gl = drawable.getGL().getGL2();

        // Setting back the color to white (default?).
        gl.glColor4d(1, 1, 1, 1);
        
        gl.glDisable(GL2.GL_LIGHTING);
        gl.glDisable(GL2.GL_BLEND);

        boolean hasFog = gl.glIsEnabled(GL2.GL_FOG);
        
        if (hasFog)
            gl.glDisable(GL2.GL_FOG);
        
        gl.glScalef(LENGTH, LENGTH, LENGTH);
        model.draw(drawable);

        if (hasFog)
            gl.glEnable(GL2.GL_FOG);
       
        gl.glEnable(GL2.GL_LIGHTING);
        gl.glEnable(GL2.GL_BLEND);
    }

    /**
     */
    public void doUpdate(long deltaTime, long time, Point3f cameraPosition)
    {
    }
}
